package com.infore.dataStatistics.main.cal.impl;

import com.infore.common.base.Msg;
import com.infore.common.base.ResultUtil;
import com.infore.dataStatistics.main.cal.Calculator;
import com.infore.dataStatistics.main.dto.StatTask;
import com.infore.dataStatistics.main.utils.DataSourceUtils;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Map;

@Slf4j
public class WqlCal extends DataSourceUtils implements Calculator, Calculator.Cal {
    @Override
    public Msg<Object> deal(Chain chain) {
        StatTask statTask = chain.getTask();
        log.info("WqlCal======>" + statTask.toString());

        if("wql".equals(statTask.getStatType())){

            List<Map<String, Object>> dataList = getDataList(statTask);

            List<Map<String, Object>> calculation = calculation(dataList, statTask);

            int updates = updateFlag(dataList, statTask);

            int saves = saveDataList(calculation, statTask);

            return ResultUtil.success(true);
        }

        return chain.proceed(statTask);
    }

    @Override
    public List<Map<String, Object>> calculation(List<Map<String, Object>> dataList, StatTask task) {
        return null;
    }

}
